package org.yty.travelagencymongodb.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.yty.travelagencymongodb.model.Entity.ChatUser;
import org.yty.travelagencymongodb.model.Entity.Result;
import org.yty.travelagencymongodb.service.ChatUserService;

@RestController
@RequestMapping("chat-user")
@RequiredArgsConstructor
public class ChatUserController {
    private final ChatUserService chatUserService;

    @GetMapping("/{id}")
    public Result<ChatUser> getChatUserById(@PathVariable String id) {
        ChatUser result = this.chatUserService.getById(id);
        if (result == null){
            return Result.error("暂无数据");
        }
        return Result.ok(result);
    }

    @DeleteMapping("/{id}")
    public Result<Void> deleteChatUserById(@PathVariable String id) {
        this.chatUserService.deleteById(id);
        return Result.ok();
    }
}
